package com.qidi.mapper.impl;

import com.qidi.mapper.OrderDao;
import com.qidi.pojo.Order;

import java.util.List;

/**
 * @author zhouXinBin
 * @create 2020-09-04-12:28
 */
public class OrderDaoimpl extends BaseDao implements OrderDao {
    @Override
    public int saveOrder(Order order) {
        String sql="insert into t_order(order_id,create_time,price,status,user_id) values(?,?,?,?,?)";
        return update(sql,order.getOrderId(),order.getCreateTime(),order.getPrice(),order.getStatus(),order.getUserId());
    }

    @Override
    public List<Order> queryMyOrder(Integer userid) {
        String sql="select order_id orderId,create_time createTime,price,status,user_id userId from t_order where user_id =?";
        return queryForList(Order.class,sql,userid);
    }

    @Override
    public List<Order> queryAllOrders(){
        String sql="select order_id orderId,create_time createTime,price,status,user_id userId from t_order";
        return queryForList(Order.class,sql);
    }

    @Override
    public int changeOrderStatus(Integer status,String orderid) {
        String sql="update t_order set status=? where order_id=? ";
        return update(sql,status,orderid);
    }


}
